import 'package:flutter/material.dart';
import 'package:xianyu_app/searchpage.dart';
class MyAppBar extends StatelessWidget implements PreferredSizeWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
//    var themData=new ThemeData();
//    var topnum=0.0;
//    var hei=0.0;
    double _statusBarHeight = MediaQuery.of(context).padding.top;//获取状态栏高度
//    switch(themData.platform){
//      case TargetPlatform.android:print("android");hei=73;print(_statusBarHeight);break;
//      case TargetPlatform.fuchsia:print("fuchsia");break;
//      case TargetPlatform.iOS:print("ios");hei=93;print(_statusBarHeight);break;
//
//    }
    return Container(
      padding: EdgeInsets.only(top:_statusBarHeight),
      height: _statusBarHeight+50,
      decoration: BoxDecoration(
          color: Colors.amberAccent
      ),
      child: Row(
        children: <Widget>[
          Image.asset("images/xianyu.png",height: 25,),
          Expanded(
            flex: 5,
            child: GestureDetector(
              onTap: (){Navigator.push(context, MaterialPageRoute(builder: (context)=>searchPage()));},
              child: Container(
                  margin: EdgeInsets.only(left: 5),
                  height: 35,
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(5)
                  ),
                  child:Row(
                    children: <Widget>[
                      Container(child: Image.asset("images/search.png",height: 20,),margin: EdgeInsets.only(left: 10,right: 5),),
                      Text("苹果手机 iphone",style: TextStyle(fontSize: 16,color:Colors.grey),)
                    ],
                  )
              ),
            ),
          ),
          Expanded(
              flex:1,
              child:Image.asset("images/sys.png",height: 25,)
          )
        ],
      ),
    ) ;

  }

  @override
  Size get preferredSize {
    return Size.fromHeight(50.0);
  }

}
class MyBody extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Center(
      child: RaisedButton(onPressed: (){Navigator.push(context, MaterialPageRoute(builder: (context){return searchPage();}));}),
    );
  }
}